package com.zj.baseproxy.model;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * 分页接收类
 *
 * @author arthur_zhou
 * @date 2023/10/8 10:51
 */
public class Page<T> {

    private long total;

    private List<T> items;

    protected Page(Long total, List<T> items) {
        this.total = Objects.isNull(total) ? 0L : total;
        this.items = items;
    }

    public static <T> Page<T> setPageData(List<T> items, Long total) {
        return new Page<>(total, items);
    }

    public static <T> Page<T> setPageData(Long total) {
        return setPageData(Collections.emptyList(), total);
    }

    public static <T> Page<T> setPageData(List<T> items) {
        return setPageData(items, 0L);
    }

    public static <T> Page<T> setPageData() {
        return setPageData(Collections.emptyList(), 0L);
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public void setItems(List<T> items) {
        this.items = items;
    }

    public Long getTotal() {
        return total;
    }

    public List<T> getItems() {
        return items;
    }
}
